use $data/Table_4_Final.dta, replace

// TABLE 4
// DEMOGRAPHICS ACROSS TREATMENTS
foreach i in control financial health{
local dispi=proper("`i'")
quietly tab apt if `i'==1
local number=`r(r)'
quietly sum floor if `i'==1 & uniqueapt==1
local fl=round(`r(mean)',.001)
local flsd=round(`r(sd)',.001) 
quietly sum haskids if `i'==1 & uniqueapt==1
local kids=round(`r(mean)',.001)
local kidssd=round(`r(sd)',.001) 
quietly sum adults if `i'==1 & uniqueapt==1
local adul=round(`r(mean)',.001)
local adulsd=round(`r(sd)',.001) 
quietly sum male if `i'==1 & uniqueapt==1
local males=round(`r(mean)',.001)
local malessd=round(`r(sd)',.001) 
quietly sum energy if `i'==1 & post==0 & energy>0
local pre=round(`r(mean)',.001)
local presd=round(`r(sd)',.001) 
display "`dispi'&`number'&`fl'&`kids'&`adul'&`males'&`pre' " //& `post'"
display "&&(`flsd') &(`kidssd')&(`adulsd')&(`malessd')&(`presd') " //& `post'"
}
// 


// HEADER FOR TABLE 4
display "Group&Number&Floor&Children&Adults&Male&Daily kWh"


// P VALUES FOR TEST OF EQUALITY FOR TABLE 4
foreach i in floor haskids adults male{
quietly oneway `i' group if uniqueapt==1
local p`i'= round(Ftail(r(df_m),r(df_r),r(F)),.01)
quietly oneway energy group if energy>0
local penergy=round(Ftail(r(df_m),r(df_r),r(F)),.01)
}
//
display "P-Value&&`pfloor'&`phaskids'&`padults'&`pmale'&`penergy'"


/*
// THIS DO FILE WILL PRODUCE THIS OUTPUT 
COPY AND PASTE THIS INTO WORD, HIGHLIGHT, AND CONVERT TEXT TO TABLE USING THE & AS THE DELIMITER

Group&Number&Floor&Children&Adults&Male&Daily kWh
Control&7&5.857&.286&1.714&.857&7.667 
&&(1.864) &(.488)&(.488)&(.378)&(10.973) 
Financial&6&5&.333&2.167&.833&6.008 
&&(2.966) &(.516)&(.983)&(.408)&(5.872) 
Health&6&5.667&.333&2&.833&14.45 
&&(3.141) &(.516)&(.894)&(.408)&(12.045) 
P-Value&&.84&.98&.6&.99&0
